/*
 * @Author       : 邱狮杰
 * @Date         : 2021-07-09 11:43:26
 * @LastEditTime: 2021-07-10 00:15:16
 * @FilePath: /professional-work-decorator/src/property/readonly.ts
 * @Description  : readonly
 */
/**
 * @description read only attribute
 * @param { T } val
 * @returns { PropertyDecorator }
 */
export function readonly<T>(val: T): PropertyDecorator {
  return function (target: Object, key: string | symbol): PropertyDescriptor {
    const desc: PropertyDescriptor = {
      writable: false,
      value: val,
    };
    return desc;
  };
}
